//Component Object
const app = getApp();
const { apiInstance } = app

Component({
  properties: {
    data: {
      type: Object,
      value: {},
      observer: function (e) {
        if (e) {

          this.setData({
            form: e,
          })
        }
      }
    },
    isEdit: {
      type: Boolean,
      value: false,
      observer: function (e) {
        if (e) {
          this.setData({
            isEdit: e,
          })
        }
      }
    },
  },
   data: {
    form: {},
    comfirmPassCurrent:'',
    contentTypeCurrent:[],
    needReCallCurrent:'',
    resultCurrent:'',
    refuseTypeCurrent:[],
    contentTypeList:[{
      id:1,
      name:'项目违法违规、不符合相关技术规范'
    },{
      id:2,
      name:'选址、内部规划不当'
    },
    {
      id:3,
      name:'采光、照明不足'
    },
    {
      id:4,
      name:'安全防护、应急设备设施不齐全'
    },
    {
      id:5,
      name:'通风、降温、降噪不到位'
    },
    {
      id:6,
      name:'资料凌乱、不齐全、表述不清'
    },
    {
      id:7,
      name:'安全标识、标线、信号装置不齐全'
    },
    {
      id:8,
      name:'防雷防静电装置不符合要求'
    },
    {
      id:9,
      name:'电气设施不符合要求'
    },
    {
      id:10,
      name:'安全距离不足'
    },
    {
      id:11,
      name:'其他'
    },
  ],
  needReCallList:[{
      id:1,
      name:'需要'
    },{
      id:2,
      name:'不需要'
    }],
    resultList:[{
      id:1,
      name:'合格'
    },{
      id:2,
      name:'不合格'
    }],
    refuseTypeList:[{
      id:1,
      name:'修改设计或重新规划'
    },{
      id:2,
      name:'补充资料'
    },
    {
      id:3,
      name:'不允许建设'
    },
    {
      id:4,
      name:'其他'
    }],
  },
  
 
  methods: {
    handleNeedReCallChange({detail}){
      this.setData({
        needReCallCurrent: detail.value,
         'form.needReCall': detail.value,
       });
    },

    handleResultChange({detail}){
      this.setData({
        resultCurrent: detail.value,
         'form.result': detail.value,
       });
    },

    handleContentTypeChange({detail}){
      this.data.contentTypeCurrent ??= [];
      const index = this.data.contentTypeCurrent?.indexOf(detail.value);
      (index == -1 || index == 'undefined') ? this.data.contentTypeCurrent.push(detail.value) : this.data.contentTypeCurrent.splice(index, 1);
      this.setData({
          contentTypeCurrent: this.data.contentTypeCurrent,
          'form.contentType': this.data.contentTypeCurrent
        });
    },
    bindValue(e){

      this.setData({
        [e.target.dataset.itemname]:e.detail.detail.value,
      });


    },

    handleRefuseTypeChange({detail}){
      this.data.refuseTypeCurrent ??= [];
      const index = this.data.refuseTypeCurrent?.indexOf(detail.value);
      (index == -1 || index == 'undefined') ? this.data.refuseTypeCurrent.push(detail.value) : this.data.refuseTypeCurrent.splice(index, 1);
        this.setData({
          refuseTypeCurrent: this.data.refuseTypeCurrent,
          'form.refuseType': this.data.refuseTypeCurrent
        });

    },
    
    
   
    
  },
  lifetimes: {
    created: async function () {

    },
    attached: function () {

    },
    ready: async function () {


    },
    moved: function () {

    },
    detached: function () {

    }
  }

});